package observer.invest.impl;

import observer.invest.Observer;
import observer.invest.Subject;

import java.util.ArrayList;
import java.util.List;

//白酒 股票
public class Liquor implements Subject {
    public int status=1;//1正常 0 停牌
    private final List<Observer> observers = new ArrayList<Observer>();

    @Override
    public String getName() {
        return "白酒";
    }

    @Override
    public void attach(Observer observer) {
        System.out.println(observer.getName()+"：订阅了白酒实时行情接口");
        observers.add(observer);
    }

    @Override
    public void detach(Observer observer) {
        observers.remove(observer);
    }

    @Override
    public void realTimeValue(int range) {
        if (range > 5) {
            for (Observer observer : observers)
                observer.onWave(this,range);
        }
        if (range > 10) {
            System.out.println("白酒涨跌幅大于10，停牌");
            status=0;
        }
    }

}
